#!/usr/bin/python
'''
Translates HAM to SAM format.
'''
import sys
import ham
import h5py
import numpy as np
import time
import logging

# parameters.
ham_file = sys.argv[1]
sam_file = sys.argv[2]

buffer = 1000000

# Open h5 dataset.
ham_obj = ham.HamRead(ham_file)

# Get array.
ham_arr = ham_obj.get_array()

# fully loaded.
fully = ham_arr[:]

# print out sam.
fout = open(sam_file, "w")
for line in fully:
	# tokenize.
	tmp = "%s\t%i\t%s\t%i\t%i\t%s\t%s\t%i\t%i\t%s\t%s\t%s\n" % (line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8], line[9], line[10], line[11] )
	fout.write(tmp)
fout.close()

